

main = sort "zbad"

count :: Ord a => a -> [a] -> Int
count x [] = 0
count x (y:yv) = if x==y then (count x yv)+1 else count x yv

search :: Ord a => a -> [a] -> Bool
search x [] = False
search x (y:yv) = x==y || (search x yv)

diff :: Ord a => a -> a -> [a] -> Int
diff x y w = (count x w) - (count y w)

issorted :: Ord a => [a] -> Bool
issorted [] = True
issorted (x:[]) = True
issorted (x:y:xs) = x <= y && (issorted (y:xs))

insort :: Ord a => a -> [a] -> [a]
insort x [] = x:[]
insort x (y:yv) = if x <= y then (x:y:yv) else y:(insort x yv) 

sort :: Ord a => [a] -> [a] 
sort [] = []
sort (x:xu) = (insort x (sort(xu)))